package cn.hdufocus.focus_helper.util;

import cn.hdufocus.focus_helper.bean.RobotBean;
import cn.hdufocus.focus_helper.entity.Reservation;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;

public class CoolQUtil {
    @Autowired
    private RobotBean robotBean;
    public static void send(Reservation reservation,String url,String destination,String messageType) {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        df.setTimeZone(TimeZone.getTimeZone("UTC"));
        Map<String, String> params = new HashMap<>();
        params.put("organization", reservation.getOrgnization());
        params.put("content", reservation.getContent());
        params.put("count", Integer.toString(reservation.getCount()));
        params.put("time", df.format(reservation.getTime()));
        params.put("username", reservation.getUsername());
        params.put("phone", reservation.getPhone());
        params.put("destination", destination);
        params.put("messageType", messageType);
        try {
            HttpClientUtil.doPostForm(url, params);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
